package com.leyou.page.controller;

import com.leyou.page.service.IPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

@Controller
public class PageController {

    @Autowired
    private IPageService pageService;

    /**
     * 查询商品详情页面数据
     * @param id
     * @return
     */
    @GetMapping("/item/{id}.html")
    public String toItemPage(@PathVariable("id") Long id, Model model) {
        Map<String,Object> itemData = pageService.toItemPage(id);
        model.addAllAttributes(itemData);
        //model.addAttribute(itemData);
        return "item";
    }
}
